# -*- coding: utf-8 -*-
import Data.ExtractData as Data
import preprocess.suffle as suffle
import DataGraph.ShowCompareResults as SR
import classifier.Fasttext as Fasttext
import classifier.SVM as SVM
import classifier.Second_Layer_SVM as SLSVM
import classifier.LR as LR
import classifier.LGBM as LGBM
import classifier.Stacking as STK
import preprocess.BaiduTitle_Embedding as BTE
import preprocess.PartitionData as PD
import classifier.PAC as PAC
import classifier.SGD as SGD
import classifier.Ridge as Ridge

data = Data.ExtractData(['Alexa','Search','World68','Hao123'],title=True)

X,Y = suffle.suffle(data.X,data.Y)

#[X,Y] = PD.partition_data('train_test',X,Y,cut_class=True,least_class_length=10)

X,Y = PD.partition_pair(X, Y, rates=[0.7, 0.3])

X_train, Y_train = X[0], Y[0]
X_test,  Y_test  = X[1], Y[1]

#METHODS = [Fasttext,SVM,LR,LGBM,PAC,SGD,Ridge]
METHODS = [Fasttext, SVM]
stacking = STK.Stacking(X_train,Y_train,X_test,Y_test,METHODS)

embedding = BTE.BaiduTitle_Embedding(stacking.X_split,X_test,'char')

result = SLSVM.Second_Layer_SVM(stacking,embedding,'off')

SR.show_compare_results(Y_test,result.predictions)